package day07;

import java.util.Scanner;

public class CalTotalAvg {
    public static void main(String[] args) {
        double[] scores=enterData();
       double total=calToal(scores);
        System.out.println("去掉一个最高分，去掉一个最低分，分数为"+total);
        System.out.println("平均分为"+total/(scores.length-2));
        calAvg(scores);
    }
    public static double[] enterData(){
        Scanner scanner=new Scanner(System.in);
        double[] scores=new double[6];
        for (int i=0;i<scores.length;i++){
            System.out.println("请第"+(i+1)+"位评委打分");
            scores[i]=scanner.nextDouble();
            if (scores[i]<0||scores[i]>100){
                i-=1;
                System.out.println("输入错误，请重新输入");
            }
        }
        return scores;
    }
    public static double calToal(double[] scores){
        double max=scores[0];
        double min=scores[0];
        double total=0;
        for (int i=0;i<scores.length;i++){
            if (scores[i]>max){
                max=scores[i];
            }
            if (scores[i]<min){
                min=scores[i];
            }
            total+=scores[i];

        }
        return total-=(max+min);
    }
    public static double calAvg(double[] scores){
        double total=calToal(scores);
        double avg=total/(scores.length-2);
        return avg;
    }
}
